package com.micro.service.controller;

import com.micro.service.annotation.ApiVersion;
import com.micro.service.entity.ResponseMessage;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@ApiVersion(1)
@RequestMapping("{version}/resources")
public class ResourceController {

    @GetMapping("/admin")
    @PreAuthorize("hasRole('ROLE_ADMIN')")
    public ResponseMessage<String> getAdmain() {
        return ResponseMessage.success("hello admin");
    }

    @GetMapping("/user")
    @PreAuthorize("hasRole('ROLE_USER')")
    public ResponseMessage<String> getUser() {
        return ResponseMessage.success("hello user");
    }

    @GetMapping("/guest")
    @PreAuthorize("hasRole('ROLE_GUEST')")
    public ResponseMessage<String> getGuest() {
        return ResponseMessage.success("hello guest");
    }

}
